package com.lj.map.syn.base;
import java.util.Map;

/**
 * Created by yangsp1 on 16/3/31.
 */
public class ThreadBean extends Thread{
    Map map;
    String threadName;
    Long sleep;
    public ThreadBean(Map map,String name,Long sleep) {
        this.map = map;
        this.threadName = name;
        this.sleep = sleep;
    }

    @Override
    public void run() {
        super.run();
        for(int i= 0; i < 3; i++) {
            if(sleep != null && sleep > 0)
            try {
                Thread.sleep(sleep);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            map.put(new HashMapKey(threadName + "_" + i), "1");
        }
        HashMapKey.threadExcedCnt.getAndIncrement();
    }
}
